<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8"/>
	<meta name="baidu-site-verification" content="JdMif0g2tL" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>angular</title>
</head>
<body>
<style type="text/css" media="screen">
	*{margin: 0;padding: 0;}
	li{list-style: none;width: 25%;float: left;text-align: center;font-size: 18px;}
	
</style>  
<div ng-app="myApp">
	<div ng-controller="myCtrl">
		<p>标题：<input type="text" ng-model="title">{{error}}</p>
		<p>标题1：<input type="text" ng-model="new.title">{{error1}}</p>
	</div>
</div>

<script type="text/javascript">
	document.getElementsByTagName('html')[0].style.fontSize=window.screen.width/10+'px';
</script>
<script src="../js/angular.min.js" charset="utf-8"></script>
<script type="text/javascript">
	var app =angular.module('myApp', []);
	app.controller('myCtrl',['$scope',function($scope){
		$scope.title='';
		$scope.new={title:''};
		//监听变量
		$scope.$watch('title', function(newValue, oldValue) {
			$scope.error=newValue.length>5?'标题长度大于5位':'';
		});
		//监听对象
		$scope.$watch('new', function(newValue, oldValue) {
			$scope.error1=newValue.title.length>5?'标题长度大于5位':'';
			console.log(newValue);
		},true);
	}])
</script>
</body>
</html>
<!--应该是14.11，时间-2017-05-08->